home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 June
/
EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso
/
earcd
/
utilsys
/
backex.lha
/
ex.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-02
|
3KB
|
126 lines
/*
backex 0.1 by Hans Bühler,
codex@studi.mathematik.hu-berlin.de
30.4.1996
*/
#include "include.h"
//-------------------------------
#define PROGNAME "BackEx 0.1"
#define FileName ((char *)Args[0])
#define OutName ((char *)Args[1])
#define InName ((char *)Args[2])
#define Quiet ((char *)Args[3])
//-------------------------------
extern char *__procname = PROGNAME;
//-------------------------------
const char Template[] = "BATCHFILE/A,OUTPUT,INPUT,QUIET/S",
DefOut[] = "CON:0/100/-1/200/ " PROGNAME " io [close window to resume]/WAIT/CLOSE/AUTO",
DefIn[] = "NIL:",
CmdHeader[] = "Execute ";
static ULONG Args[4] = { 0,
(ULONG)DefOut,
(ULONG)DefIn,
FALSE
};
//-------------------------------
/*******************************
* Requester with various args *
*******************************/
LONG PutTxtArgs(char *txt, char *gad, APTR arg1, APTR arg2)
{
struct EasyStruct easy;
APTR args[2];
args[0] = arg1;
args[1] = arg2;
easy.es_StructSize = sizeof(struct EasyStruct);
easy.es_Flags = 0;
easy.es_Title = __procname;
easy.es_TextFormat = txt;
easy.es_GadgetFormat = gad ? gad : "Resume";
return EasyRequestArgs(0,&easy,0,args);
}
//-------------------------------
void main(void) // cback.o
{
APTR args;
BPTR in,out;
char *cmd;
LONG i;
if(!( args = ReadArgs(Template,Args,0) ))
{
PutTxtArgs( "%s from Codex Design Software\n"
"(w)30.4.1996 Hans Bühler\n"
"[" EMAIL "]\n"
"\n"
"Args: %s\n"
"\n"
"Executes a batchfile in background\n"
"using the specified i/o handles;\n"
"freeware.","<read dox>",__procname,Template);
return;
}
if(!( cmd = AllocVec(i = strlen(FileName) + 1 + strlen(CmdHeader) + 1,MEMF_PUBLIC|MEMF_CLEAR) ))
{
PutTxtArgs( "Out of memory;\n"
"Can't allocate %ld bytes.",0,(APTR)i,0);
}
else
{
strcpy(cmd,CmdHeader);
strcat(cmd,FileName);
if(!( out = Open(OutName,MODE_OLDFILE) ))
{
PutTxtArgs("Can't open '%s' (output):\nDOS error #%ld !",0,OutName,(APTR)IoErr());
}
else
{
if(!( in = Open(InName,MODE_OLDFILE) ))
{
PutTxtArgs("Can't open '%s' (input):\nDOS error #%ld !",0,InName,(APTR)IoErr());
}
else
{
i = SystemTags(cmd, SYS_Input, in,
SYS_Output, out,
TAG_END);
if(i < 0)
{
PutTxtArgs( "Failed to execute '%s':\n"
"DOS error #%ld",0,(APTR)FileName,(APTR)IoErr());
}
else
if(!i && !Quiet)
PutTxtArgs( "'%s' returned\n"
"error code #%ld !",0,FileName,(APTR)i);
Close(in);
}
Close(out);
}
FreeVec(cmd);
}
FreeArgs(args);
}